home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / CompareTextAndImageCells.java < prev    next >
Text File  |  1998-08-21  |  2KB  |  75 lines

  1. package symantec.itools.awt.multiList;
  2.  
  3. import java.util.BitSet;
  4. import symantec.itools.awt.CompareCells;
  5. import java.util.ResourceBundle;
  6.  
  7. // 07/14/97    LAB    Separeated from Multilist.java. Made public to accommodate future
  8. //                extendibility of the MultiList class.
  9.  
  10. /**
  11.  * This is a helper class to the MultiList class.
  12.  * It is used to compare Cells of the MultiList.
  13.  * @version 1.1, July 14, 1997
  14.  * @author Symantec
  15.  */
  16. public class CompareTextAndImageCells
  17.     extends CompareCells
  18. {
  19.     /**
  20.      * Constructs a CompareTextAndImageCells object.
  21.      */
  22.     public CompareTextAndImageCells()
  23.     {
  24.         errors = ResourceBundle.getBundle("symantec.itools.resources.ErrorsBundle");
  25.     }
  26.  
  27.     /**
  28.      * Compares the value of two objects.
  29.      * @param o1 the first object
  30.      * @param o2 the second object
  31.      * @return 0 if the object's values are equal, less than 0 if the first
  32.      * object's value is less than the second object's value, and greater
  33.      * than 0 if the first object's value is greater than the second
  34.      * object's value
  35.      * @param o1 the first object
  36.      * @param o2 the second object
  37.      */
  38.     public int compareObjects(Object o1, Object o2)
  39.     {
  40.         TextAndImageCell c1;
  41.         TextAndImageCell c2;
  42.  
  43.         c1 = null;
  44.         c2 = null;
  45.  
  46.         if(o1 instanceof TextAndImageCell)
  47.         {
  48.             c1 = (TextAndImageCell)o1;
  49.         }
  50.         else
  51.         {
  52.             throw new IllegalArgumentException(errors.getString("NotCellObject"));
  53.         }
  54.  
  55.         if(o2 instanceof TextAndImageCell)
  56.         {
  57.             c2 = (TextAndImageCell)o2;
  58.         }
  59.         else
  60.         {
  61.             throw new IllegalArgumentException(errors.getString("NotCellObject"));
  62.         }
  63.  
  64.         String o1Text = (c1 != null) ? c1.getText() : "";
  65.         String o2Text = (c2 != null) ? c2.getText() : "";
  66.  
  67.         return o1Text.compareTo(o2Text);
  68.     }
  69.  
  70.     /**
  71.      * Error strings.
  72.      */
  73.     transient protected ResourceBundle errors;
  74. }
  75.